<%--

<!------------------------------------------------------------------------------
 - Copyright 2006 CORE Solutions Limited
 - All rights reserved.
 - PROPRIETARY AND CONFIDENTIAL INFORMATION.
 - Use is subject to license terms.
 -
 - FUNCTION ID      :   ACCESS_RIGHT
 - AUTHOR           :   Victor Zheng 
 - DATE CREATE      :   2006/02/01
 - DESCRIPTION      :   a CHILD TAB JSP file for the function, ACCESS_RIGHT
 -                  :   
 -                  :   
 -                  :   
 -
 - MODIFICATION HISTORY:
 - DATE         AUTHOR          VERSION NO.         COMMENT
 - -----------  --------------  ------------------  -------------------
 - 2006/02/01   Victor Zheng    1.0                 source is generated.
 - 2006/06/20   William Xu      1.0                 BugZilla #6277
 -
 -
------------------------------------------------------------------------------->

--%> 
<%@ include file="/jsp/com/erp/app/common/jsp/directives_include.jsp"%>

<%@ page import="com.erp.app.admin.accessRight.vo.AccessRightDtlVo"%>
<%@ page import="com.erp.app.admin.accessRight.web.AccessRightMaintenanceAction"%>
<%@ page import="com.erp.app.admin.accessRight.web.AccessRightMaintenanceForm"%>
<%@ page import="com.erp.app.admin.accessRight.web.AccessRightDtlRow"%>
<%@ page import="com.erp.framework.util.user.User"%>

<%@ include file="/jsp/com/erp/app/common/jsp/html_include.jsp"%>

<jsp:useBean id="accessRightMaintenanceForm" scope="session" type="com.erp.app.admin.accessRight.web.AccessRightMaintenanceForm" />

<%
ArrayList accessRightDtlList = accessRightMaintenanceForm.getMultiRows(AccessRightMaintenanceAction.TAB_IDX_DTL);
pageContext.setAttribute("accessRightDtlList", accessRightDtlList);
User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

rowReadOnly = false;
%>

<div class="footerbuttons"><chtml:button form="accessRightMaintenanceForm" pageEvent="<%=AccessRightMaintenanceAction.ACTION_ADD_DTL%>" styleClass="button1" disabled="<%=String.valueOf(rowReadOnly)%>"/></div>

<!-- MUST use the following example to mark fields as mandatory field inputs-->
<!--
<td class="grid_header" nowrap><span class="mandatory_label">
<bean:message key="label.general.mandatory.field"/>
...</span></td>
-->
<%
TableSchema[] childTsArray = accessRightMaintenanceForm.getChildTs();
TableSchema childTs = childTsArray[AccessRightMaintenanceAction.TAB_IDX_DTL];
%>

<table class="table_short_grid">

	<tr class="grid_header">
		<%
			webLabel = childTs.getDisplayWebLabelByObjectId("LBL_DTL_DELETE");
		%>
		<td class="grid_header_col_narrow" nowrap>
			
			<%=webLabel%>
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" childTsIndex="current" property="dtlLineNo" />
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" childTsIndex="current" property="dtlDept" />
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" childTsIndex="current" property="dtlUserCode" />
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" childTsIndex="current" property="dtlStatus" />
		</td>		
	</tr>

	<logic:iterate id="accessRightDtlRow" name="accessRightDtlList" indexId="idx" length="<%=String.valueOf(ProjectConstants.MAX_DISPLAY)%>" offset="<%=String.valueOf(accessRightMaintenanceForm.getSidx())%>">

	<%
		AccessRightDtlRow row = (AccessRightDtlRow) accessRightDtlRow;
	%>

	<% if((row != null) && (CommonUtil.isEmpty(row.getIsDelete()))) {%>

	<tr <%=(idx.intValue()%2 == 0)? "class='grid_result1'": "class='grid_result2'"%>>
		<td nowrap>
			<input type="checkbox" name="isDelete" value="<%= row.getIdx()%>" <%=rowReadOnly ? "disabled=\"true\"" : ""%>/>
		</td>
		<td nowrap>
			<bean:write name="accessRightDtlRow" property="dtlLineNo" filter="true"/>
		</td>
		<td nowrap>
			<html:text useExtensions="true" uiType="combobox" name="accessRightDtlRow" property="dtlDept" showCode="false"/>
		</td>
		<td nowrap>
			<%
			String allIsSelected = "";
			String ownerIsSelected = "";
			if ((ProjectConstants.ACCESS_RIGHT_TYPE_ALL).equals(row.getDtlUserCode())){
				allIsSelected = "selected";
			} else if ((ProjectConstants.ACCESS_RIGHT_TYPE_OWNER).equals(row.getDtlUserCode())) {
				ownerIsSelected = "selected";
			}
			%>
			<select name="dtlUserCode"  <%=formReadOnly ? "disabled=\"true\"" : ""%> class="selectBox1">
				<option value="" >
				<option value="<%=ProjectConstants.ACCESS_RIGHT_TYPE_ALL%>" <%=allIsSelected%>><%=ProjectConstants.ACCESS_RIGHT_TYPE_ALL%></option>
				<option value="<%=ProjectConstants.ACCESS_RIGHT_TYPE_OWNER%>" <%=ownerIsSelected%>><%=ProjectConstants.ACCESS_RIGHT_TYPE_OWNER%></option>
			</select>
			<%--
				// now use ALL and OWNER only 2006-02-28
			
			<select name="dtlUserCode"  <%=formReadOnly ? "disabled=\"true\"" : ""%> class="selectBox1">
			<% where = "COMPANY_CODE = '"+WebUtil.getAppropriateCompanyCode(session, ProjectConstants.SP_SHARE_USER_SETUP) + "'";%>
				<option value="" >
				<option value="ALL" <%=allIsSelected%>>ALL</option>
				<chtml:options table="t_user"
				valuecolumn="user_code"
				textcolumn="user_name"
				where= "<%=where%>"
				order="user_name"
				selected="<%=row.getDtlUserCode()%>" />
			</select>
			--%>
		</td>
		<td nowrap>
			<html:text useExtensions="true" uiType="combobox" name="accessRightDtlRow" property="dtlStatus" showCode="false" />
		</td>		
	</tr>

	<%} else { %>

		<html:hidden property="isDelete" value="<%=row.getIdx()%>"/>

		<!--MUST INCLUDE hidden fields for all input objects such as textbox, textarea, check box, radio button, select box, etc.-->
		<html:hidden property="dtlDept" value="<%=CommonUtil.nullToString(row.getDtlDept())%>"/>
		<html:hidden property="dtlUserCode" value="<%=CommonUtil.nullToString(row.getDtlUserCode())%>"/>
		<html:hidden property="dtlStatus" value="<%=CommonUtil.nullToString(row.getDtlStatus())%>"/>

	<%} %>

		<html:hidden property="idx" value="<%=row.getIdx()%>" />
		<html:hidden property="rowMode"  value="<%=row.getRowMode()%>"/>

	</logic:iterate>

</table>

